<template>
  <transition v-if="visible" name="modal-fade">
    <div class="te-modal" @click.self="onCloseClick">
      <div class="te-modal-body">
        <div class="te-modal-header">
          <div class="te-modal-title">
            <slot name="title">Title</slot>
          </div>
          <div class="te-modal-close-btn" @click.stop="onCloseClick">
            <svg
              t="1589288656790"
              class="icon"
              viewBox="0 0 1366 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="5225"
              width="24"
              height="24"
            >
              <path
                d="M573.207 527.834l404.184-404.22a52.811 52.811 0 0 0 0-74.401l-2.217-2.217a52.836 52.836 0 0 0-74.413 0l-404.209 404.73-404.22-404.9a52.823 52.823 0 0 0-74.401 0l-2.217 2.217a51.915 51.915 0 0 0 0 74.414l404.22 404.377-404.22 404.22a52.823 52.823 0 0 0 0 74.402l2.217 2.217a52.811 52.811 0 0 0 74.401 0l404.22-404.22 404.22 404.22a52.823 52.823 0 0 0 74.414 0l2.217-2.217a52.811 52.811 0 0 0 0-74.401z m0 0"
                p-id="5226"
                fill="#1296db"
              />
            </svg>
          </div>
        </div>
        <div class="te-modal-content">
          <slot :event="onEventEmit" name="content"></slot>
        </div>
        <div class="te-modal-footer">
          <slot name="footer"></slot>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  inheritAttrs: false,
  components: {},
  data() {
    return {};
  },
  props: {
    event: {
      required: true,
      default: {}
    },
    visible: Boolean
  },
  methods: {
    onCloseClick() {
      this.$emit("close");
    },
    onEventEmit() {
      this.$emit("modalEvent", this.event);
    }
  }
};
</script>

<style scoped>
.modal-fade-enter-active,
.modal-fade-leave-active {
  transition: opacity 0.2s;
}

.modal-fade-enter,
.modal-fade-leave-to {
  opacity: 0;
}

.te-modal {
  backdrop-filter: blur(1.8px);
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  left: 0;
  top: 0;
  background: rgba(20, 20, 20, 0.6);
  z-index: 200;
}

.te-modal-body {
  background: #262626;
  padding: 26px 0;
  /* border-radius: 8px; */
}

.te-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #484848;
  padding: 0px 40px 16px 40px;
  margin-bottom: 24px;
  /* padding-bottom: 12px; */
  /* margin-bottom: 20px; */
}

.te-modal-content {
  padding: 0px 40px;
}

.te-modal-title {
  margin-right: 20px;
  /* font-size: 1.275em; */
}

.te-modal-close-btn {
  cursor: pointer;
  width: 20px;
  height: 20px;
}

.te-modal-close-btn path {
  fill: #fff;
}

.te-modal-footer {
  padding: 0px 40px;
}
</style>
